
const Koa = require('koa');
const app = new Koa();
const passport = require('koa-passport')
const KoaBody = require('koa-body');
const Router = require('koa-router')
const router = new Router()
app.use(KoaBody())
const cors = require("koa-cors")
const db = require('../config/keys')
const port = process.env.PORT || 8000
const mongoose = require('mongoose')
const users = require('../router/api/user')
const profile = require('../router/api/profile')
app.use(cors())
app.use(passport.initialize())
app.use(passport.session())
require('../config/passport')(passport)
router.use('/api/users', users)
router.use('/api/profile', profile)
app.use(router.routes()).use(router.allowedMethods())
mongoose.connect(db.mongoDBURI, { useNewUrlParser: true })
    .then(
        () => {
            console.log('mongodb连接成功');
        }).catch(() => {

        })
app.listen(port, () => {
    console.log(`open part 8000`);
})